package com.easy.config;

import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.SimpleScheduleBuilder;
import org.quartz.TriggerBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.Trigger;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

@Configuration
public class QuartzConfig {
//
//    @Bean
//    public JobDetail orderTimeoutJobDetail() {
//        return JobBuilder.newJob(OrderTimeoutJob.class)
//                .withIdentity("orderTimeoutJob")
//                .storeDurably()
//                .build();
//    }
//
//    @Bean
//    public Trigger orderTimeoutTrigger() {
//        // 这里使用SimpleScheduleBuilder作为示例，但你可能需要使用CronScheduleBuilder来设置更复杂的调度计划
//        return TriggerBuilder.newTrigger()
//                .forJob(orderTimeoutJobDetail())
//                .withIdentity("orderTimeoutTrigger")
//                .withSchedule(SimpleScheduleBuilder.simpleSchedule()
//                        .withIntervalInSeconds(10) // 每10秒执行一次
//                        .repeatForever())
//                .build();
//    }
//
//    @Bean
//    public SchedulerFactoryBean schedulerFactoryBean(Trigger orderTimeoutTrigger, JobDetail orderTimeoutJobDetail) {
//        SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
//        schedulerFactoryBean.setTriggers(new Trigger[]{orderTimeoutTrigger});
//        schedulerFactoryBean.setJobDetails(new JobDetail[]{orderTimeoutJobDetail});
//        return schedulerFactoryBean;
//    }
}
